package com.burgeon.backend.Rest.Tool;
/**
 * 获取用户信息
 */


import com.burgeon.backend.Rest.base.RESTBase;
import org.json.JSONArray;
import org.springframework.util.MultiValueMap;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class ISUsable extends RESTBase {

    private String ip;
    private String account;
    private String password;

    public ISUsable(String ip, String account, String password) {
        this.ip = ip;
        this.account = account;
        this.password = password;
    }

    /**
     * 发送并接收字符创
     */

    public String getData() throws Exception {
        String url = "http://"+ip+"/servlets/binserv/Rest";

        String str = RESULT(Data(),url);
        System.err.println(str);

        return new JSONArray(str).getJSONObject(0).getString("code");
    }

    private MultiValueMap Data() {
        HashMap params = new HashMap();
        ArrayList columns = new ArrayList();//查询字段
        columns.add("CARDNO");
        columns.add("ID");

        params.put("columns", columns);
        params.put("table", "C_VIP");//表名

        params.put("range","1");
        return DATA("Query", params,account,password);
    }

    public static void main(String[] args) {
        ISUsable isUsable = new ISUsable("39.99.239.133:55322", "nea@burgeon.com.cn", "burgeon55321");
        try {
            System.err.println(isUsable.getData());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
